package com.qi.demo01.UnSafe;

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author zjq
 * @date 2020/3/25 21:17
 * <p>
 * java.util.ConcurrentModificationException
 */
public class MapTest {
    public static void main(String[] args) {
        //map 是这样用的吗？ 默认等价于什么?

        //initialCapacity 初始容量
        //loadFactor 加载因子
        //研究ConcurrentHashMap

//        Map<String,String> Map = new HashMap<>();
        Map<String, String> map = new ConcurrentHashMap<>();
        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                map.put(Thread.currentThread().getName(), UUID.randomUUID().toString().substring(0, 5));
                System.out.println(map);
            }, String.valueOf(i)).start();
        }
    }
}
